package com.bauer.base.concurrent;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
import java.util.concurrent.TimeUnit;

/**
 * @Author ：rui.wei
 * @Date ：Created in 11:13 2019/4/24
 * @Description：
 */
public class ThreadPool {

    private static ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 4, 0L, TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(2),new CallerRunsPolicy());


    public static void main(String[] args) {

        executor.execute(new DemoRunnable("1", 1000));
        executor.execute(new DemoRunnable("2", 1000));
        executor.execute(new DemoRunnable("3", 1000));
        executor.execute(new DemoRunnable("4", 1000));
        executor.execute(new DemoRunnable("5", 1000));
        executor.execute(new DemoRunnable("6", 1000));
        executor.execute(new DemoRunnable("7", 1000));
        executor.execute(new DemoRunnable("8", 1000));
        executor.execute(new DemoRunnable("9", 1000));
        executor.execute(new DemoRunnable("10", 1000));

        System.out.println("finish");
        executor.shutdown();
        int i = 0;
    }


}
